package metier.cases;

import java.awt.Image;
import java.io.File;

import javax.imageio.ImageIO;

import metier.event.Evenement;

public class Case {
	private boolean parcourable;
	private Image[] images;
	private String[] addrImages;
	private boolean etat; //Activé ou non
	private Evenement parcourue;
	private Evenement quittee;
	private Evenement actionee;
	
	public Case(boolean parcourable, String[] addrImages, boolean etat) {
		super();
		this.parcourable = parcourable;
		this.etat = etat;
		this.parcourue = null;
		this.quittee = null;
		this.actionee = null;
		this.addrImages = addrImages;
		
		images = new Image[addrImages.length];
		for(int i = 0; i < images.length; i++) {
			try {
				images[i] = ImageIO.read(new File("images/"+addrImages[i]));
			} catch (Exception e) {
				e.printStackTrace();
			}
		}
	}
	
	public Image[] getImages() {
		return images;
	}
	
	public Image getImageEnCours() {
		if(!etat)
			return images[0];
		else
			return images[1];
	}
	
	public String[] getAddrImages() {
		return addrImages;
	}
	
	public void setEventParcourue(Evenement e) {
		this.parcourue = e;
	}
	
	public void setEventQuittee(Evenement e) {
		this.quittee = e;
	}
	
	public void setEventActionnee(Evenement e) {
		this.actionee = e;
	}
	
	public void setEtat(boolean etat) {
		this.etat = etat;
	}
	
	public void setParcourable(boolean parcourable) {
		this.parcourable = parcourable;
	}
	
	public boolean getEtat() {
		return etat;
	}
	
	public boolean parcourable() {
		return parcourable;
	}
	
	public void parcourue() {
		parcourue.run();
	}
	
	public void quittee() {
		quittee.run();
	}
	
	public void actionee() {
		actionee.run();
	}
}
